#include <iostream>
#include <vector>

using namespace std;

/*
5 5
3 3
9 0 6 2 2
9 7 6 2 10
3 5 9 9 7
7 5 8 0 5
2 9 6 5 5
*/

// 均值滤波
double blur(vector<vector<double> > src, int height_src, int width_src, int r, int c, int height_filter, int width_filter)
{
    double num = 0;

    for (int rr=r-height_filter/2; rr<=r+height_filter/2; rr++)
    {

        if (rr < 0 || rr >= height_src)
            continue;
        for (int cc=c-width_filter/2; cc<=c+width_filter/2; cc++)
        {
            if (cc<0 || cc>=width_src)
                continue;
            
            num += src[rr][cc];
        }
    }

    return num / (height_filter*width_filter);
}

// 四舍五入
int round(double num)
{
    if (int(num * 10) % 10 >= 5)
        return int(num+1);
    
    return int(num);
}
int main()
{
    // 原图高宽、滤波核高宽
    int height_src, width_src, height_filter, width_filter;
    cin >> height_src;
    cin >> width_src;
    cin >> height_filter;
    cin >> width_filter;

    // 存储图片数据
    vector<vector<double> > src;
    vector<double> temp;

    double num;
    for (int r = 0; r < height_src; r++)
    {
        for (int c = 0; c < width_src; c++)
        {
            cin >> num;
            temp.push_back(num);
        }
        src.push_back(temp);
        temp.clear();
    }

    // 输出均值滤波结果
    
    for (int r = 0; r < height_src; r++)
    {
        for (int c = 0; c < width_src; c++)
        {
            // 获取均值
            double num1 = blur(src, height_src, width_src, r, c, height_filter, width_filter);

            // 四舍五入
            cout << round(num1) << " ";
        }
        cout << endl;
    }

    return 0;
}